package com.appli.ImpossibleQuestSeason1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class ImpossibleQuestSeason1Episode1 extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.episode1);
        ((Button)findViewById(R.id.ButtonSkipEpisode)).setVisibility(View.GONE);
        ((Button)findViewById(R.id.ButtonSkipEpisode)).setOnClickListener(this);
        ((Button)findViewById(R.id.ButtonAnswerEpisode1)).setOnClickListener(this);
        ((ImageView)findViewById(R.id.ImageEpisode1)).setOnClickListener(this);
        ((TextView)findViewById(R.id.AnswerEpisode1)).setVisibility(View.GONE);
        ((Button)findViewById(R.id.ButtonAnswerEpisode1)).setVisibility(View.GONE);
    }

	@Override
	public void onClick(View v) {
		try{
			switch (v.getId()){
				case R.id.ImageEpisode1:				
					Toast.makeText(this, "SOME LETTERS COULD BE MATHEMATICAL OPERATORS", Toast.LENGTH_LONG).show();
			        ((TextView)findViewById(R.id.AnswerEpisode1)).setVisibility(View.VISIBLE);
			        ((Button)findViewById(R.id.ButtonAnswerEpisode1)).setVisibility(View.VISIBLE);
				break;
				case R.id.ButtonAnswerEpisode1:
					if ( !("".equals(((EditText)findViewById(R.id.AnswerEpisode1)).getText().toString())) && 
							((EditText)findViewById(R.id.AnswerEpisode1)).getText().toString().equals("3328")){
						Toast.makeText(this, "Bzzzzzzzt ! Clic !", Toast.LENGTH_LONG).show();
				        ((Button)findViewById(R.id.ButtonSkipEpisode)).setVisibility(View.VISIBLE);
				        ((TextView)findViewById(R.id.AnswerEpisode1)).setVisibility(View.GONE);
				        ((Button)findViewById(R.id.ButtonAnswerEpisode1)).setVisibility(View.GONE);
					}else{
						Toast.makeText(this, "WRONG PASSWORD", Toast.LENGTH_LONG).show();
						((TextView)findViewById(R.id.AnswerEpisode1)).setText("");
					}
				break;
				case R.id.ButtonSkipEpisode:
					Intent j = new Intent(this, ImpossibleQuestSeason1Episode2.class);
					startActivity(j);
				break;
			}
    	}catch (Exception E){
    		E.printStackTrace();
		}
	}
}